package cn.zhf.shop.controller;


import cn.zhf.shop.entity.Message;
import cn.zhf.shop.entity.PublicityPictures;
import cn.zhf.shop.entity.Refund;
import cn.zhf.shop.service.PublicityPicturesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "宣传图片管理")
@RequestMapping("/api/PublicityPictures")
public class PublicityPicturesController {
    @Resource
    private PublicityPicturesService publicityPicturesService;


    @PostMapping("/")
    @ApiOperation(value = "上传宣传图片")
    public Message<?> insert(PublicityPictures r){
        return publicityPicturesService.insert(r);
    }

    @GetMapping("/one")
    @ApiOperation(value = "根据id查看图片")
    public Message selectById(int id){
        return publicityPicturesService.selectByPrimaryKey(id);
    }

    @GetMapping("/all")
    @ApiOperation(value = "查看所有图片")
    public Message selectAll(){
        return publicityPicturesService.selectAll();
    }

    @GetMapping("/group")
    @ApiOperation(value = "根据 组id 查看图片")
    public Message selectByGroup(int group){
        return publicityPicturesService.selectByPublicityPicturesGroup(group);
    }

    @PutMapping("/one")
    @ApiOperation(value = "修改图片")
    public Message update(PublicityPictures publicityPictures){
        return publicityPicturesService.updateByPrimaryKeySelective(publicityPictures);
    }

    @PutMapping("/order")
    @ApiOperation(value = "根据id修改顺序")
    public Message updateOrderById(Integer updatedPublicityPicturesOrder, Integer publicityPicturesId){
        return publicityPicturesService.updatePublicityPicturesOrderByPublicityPicturesId(updatedPublicityPicturesOrder, publicityPicturesId);
    }

    @DeleteMapping("/")
    @ApiOperation(value = "根据id删除图片")
    public Message deleteById(int id){
        return publicityPicturesService.deleteByPrimaryKey(id);
    }
}
